home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / nivb / mess.frm < prev    next >
Text File  |  1995-05-07  |  6KB  |  200 lines

  1. VERSION 2.00
  2. Begin Form MessForm 
  3.    Caption         =   "Message Services Test"
  4.    ClientHeight    =   2175
  5.    ClientLeft      =   1710
  6.    ClientTop       =   1575
  7.    ClientWidth     =   5760
  8.    Height          =   2580
  9.    Left            =   1650
  10.    LinkMode        =   1  'Source
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   2175
  13.    ScaleWidth      =   5760
  14.    Top             =   1230
  15.    Width           =   5880
  16.    Begin ComboBox ServerNameBox 
  17.       Height          =   300
  18.       Left            =   1200
  19.       TabIndex        =   7
  20.       Top             =   240
  21.       Width           =   2535
  22.    End
  23.    Begin TextBox MessageBox 
  24.       Height          =   375
  25.       Left            =   1200
  26.       TabIndex        =   1
  27.       Top             =   1680
  28.       Width           =   4455
  29.    End
  30.    Begin ListBox UserNameBox 
  31.       Height          =   810
  32.       Left            =   1200
  33.       Sorted          =   -1  'True
  34.       TabIndex        =   6
  35.       Top             =   720
  36.       Width           =   2535
  37.    End
  38.    Begin CommandButton CancelButton 
  39.       Caption         =   "Cancel"
  40.       Height          =   375
  41.       Left            =   4320
  42.       TabIndex        =   3
  43.       Top             =   720
  44.       Width           =   855
  45.    End
  46.    Begin CommandButton SendButton 
  47.       Caption         =   "Send"
  48.       Default         =   -1  'True
  49.       Height          =   375
  50.       Left            =   4320
  51.       TabIndex        =   2
  52.       Top             =   240
  53.       Width           =   855
  54.    End
  55.    Begin Label Label2 
  56.       Alignment       =   1  'Right Justify
  57.       Caption         =   "Message:"
  58.       Height          =   255
  59.       Left            =   240
  60.       TabIndex        =   4
  61.       Top             =   1680
  62.       Width           =   855
  63.    End
  64.    Begin Label Label3 
  65.       Alignment       =   1  'Right Justify
  66.       Caption         =   "User:"
  67.       Height          =   255
  68.       Left            =   600
  69.       TabIndex        =   5
  70.       Top             =   720
  71.       Width           =   495
  72.    End
  73.    Begin Label Label1 
  74.       Alignment       =   1  'Right Justify
  75.       Caption         =   "File Server:"
  76.       Height          =   255
  77.       Left            =   0
  78.       TabIndex        =   0
  79.       Top             =   240
  80.       Width           =   1095
  81.    End
  82. End
  83. Dim conns(MAX_CONNS) As Long
  84. Dim results As String * MAX_CONNS
  85.  
  86. Sub Form_Unload (Cancel As Integer)
  87.     SetPreferredConnectionID (originalPrefConnID%)
  88. End Sub
  89.  
  90. Sub SendButton_Click ()
  91.     Static results(MAX_CONNS) As Integer
  92.     
  93.     ccode% = GetConnectionID(ServerNameBox.Text, connID%)
  94.     If (ccode% <> SUCCESSFUL) Then
  95.         MsgBox "Unable to get connection ID of server " + prefServer$, MB_OK, "Error"
  96.     Else
  97.         SetPreferredConnectionID (connID%)
  98.  
  99.         userName$ = UserNameBox.Text
  100.         If (Len(userName$) > 0) Then
  101.             userName$ = Left$(userName$, InStr(userName$, " ") - 1)
  102.             msgText$ = MessageBox.Text
  103.             connNum& = Val(Mid$(UserNameBox.Text, InStr(UserNameBox.Text, "[") + 1))
  104.  
  105.             ccode% = SendBroadcastMessage(msgText$, connNum&, results(0), 1)
  106.             If (ccode% <> SUCCESSFUL) Then
  107.                 MsgBox "Unable to send message to user " + userName$, MB_OK, "Error"
  108.             Else
  109.                 Select Case (results(0) And &HFF)
  110.                     Case &H0
  111.                         MsgBox "Message sent to user " + userName$, MB_OK, "Message Sent"
  112.                     Case &HFC
  113.                         MsgBox userName$ + "'s message buffer is full", MB_OK, "Warning"
  114.                     Case &HFD
  115.                         MsgBox "Invalid connection number", MB_OK, "Error"
  116.                     Case &HFF
  117.                         MsgBox "User " + userName$ + " is blocking messages", MB_OK, "Warning"
  118.                     Case Else
  119.                         MsgBox "Unknown error while sending message", MB_OK, "Error"
  120.                 End Select
  121.             End If
  122.         End If
  123.     End If
  124. End Sub
  125.  
  126. Sub ServerNameBox_Change ()
  127.     UpdateUserNameList
  128.     SetMessageBoxText
  129. End Sub
  130.  
  131. Sub ServerNameBox_Click ()
  132.     UpdateUserNameList
  133.     SetMessageBoxText
  134. End Sub
  135.  
  136. Sub SetMessageBoxText ()
  137.     Dim logTime As DATE_AND_TIME
  138.     Dim oName As String * 48
  139.     
  140.     connNum& = GetConnectionNumber()
  141.     ccode% = GetConnectionInformation(connNum&, oName, oType%, oID&, logTime)
  142.     If (ccode% <> SUCCESSFUL) Then
  143.         MsgBox "Unable to get user name for your connection", MB_OK, "Error"
  144.     Else
  145.         msgText$ = Left$(oName, InStr(oName, Chr$(0)) - 1)
  146.         msgText$ = msgText$ + " [" + Format$(connNum&) + "]" + ":"
  147.         MessageBox.Text = msgText$
  148.     End If
  149. End Sub
  150.  
  151. Sub UpdateUserNameList ()
  152.     Dim oName As String * 48
  153.     Dim serverInfo As FILE_SERV_INFO
  154.     Dim logTime As DATE_AND_TIME
  155.     
  156.     ccode% = GetConnectionID(ServerNameBox.Text, connID%)
  157.     If (ccode% <> SUCCESSFUL) Then
  158.         MsgBox "Unable to get connection ID of user " + UserNameBox.Text, MB_OK, "Error"
  159.     Else
  160.         SetPreferredConnectionID (connID%)
  161.     
  162.         UserNameBox.Clear
  163.         ccode% = GetServerInformation(54, serverInfo)
  164.         If (ccode% <> SUCCESSFUL) Then
  165.             MsgBox "Unable to get number of users supported from default file server", MB_OK, "Error"
  166.         Else
  167.             For conn& = 1 To (serverInfo.maxConnectionsSupported And 255)
  168.                 ccode% = GetConnectionInformation(conn&, oName, oType%, oID&, logTime)
  169.                 If ((ccode% = SUCCESSFUL) And (oType% = OT_USER)) Then
  170.                     temp$ = Left$(oName, (InStr(oName, Chr$(0)) - 1))
  171.                     temp$ = temp$ + " [" + Format$(conn&) + "]"
  172.                     UserNameBox.AddItem temp$
  173.                 End If
  174.             Next conn&
  175.         End If
  176.     End If
  177. End Sub
  178.  
  179. Sub CancelButton_Click ()
  180.     Unload MessForm
  181. End Sub
  182.  
  183. Sub Form_Load ()
  184.     Dim fileServerName As String * 48
  185.  
  186.     For connID% = 1 To 8
  187.         If (IsConnectionIDInUse(connID%) = 1) Then
  188.             GetFileServerName connID%, fileServerName
  189.             ServerNameBox.AddItem fileServerName
  190.         End If
  191.     Next connID%
  192.  
  193.     fileServerName = GetDefaultFileServerName()
  194.     ServerNameBox.Text = fileServerName
  195.  
  196.     Call UpdateUserNameList
  197.     SetMessageBoxText
  198. End Sub
  199.  
  200.